home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagn_r.zip / RECORDS.SWG / 0011_Records in ASM.pas < prev    next >
Pascal/Delphi Source File  |  1994-01-27  |  2KB  |  46 lines

  1. {
  2.  To access record fields in Assembler you should define a Register to the
  3. ofset of the variable s or Record..
  4. Example:
  5. }
  6. Type MyRec = Record
  7.        Hi :Byte;
  8.        Lo :Word;
  9.        S :String[90];
  10.       End;
  11. Var
  12.  Yup :MyRec;
  13. Begin
  14. asM
  15.        Mov     DI, Seg Yup;
  16.        Push    DI;     { Save it just incase folloing code uses DI }
  17.        { do what evr code you wish }
  18.        Pop     DI      { Get back our pointer }
  19.        Mov     [DI+MyRec.Hi], AL;      { Lets say AL was the reg u want }
  20.        Mov     [DI+RyRec.Lo], BX;
  21.        { Ect }
  22. {       ....
  23. Remember, if you enter an assembler rountine that passes a Array of Records
  24. then you must Load AX with the size of Your Record, Take the Array Pointer
  25. Index Times The AX using the MUL instructions then SubTrace the Size of the
  26. Record from the AX which would be the Results fo the multiply and then add
  27. that to the DI for a Total Offset to the correct Record;
  28. Example:
  29.  I want Record # 2
  30. }
  31. Procedure Test( AR:Array[1..4] of MyRec);
  32.  Begin
  33.   ASm
  34.    Mov Di, Offset AR;
  35.    Mov AX, TypeOF(MyRec);      { This generates the Size of the Record }
  36.    MUL AX, 2;                  { I want to times it by 2 }
  37.    SUB AX, TypeOf(MyRec);
  38.    ADD DI,AX;
  39.    { Now the DI pointers to the start of the #2 Record }
  40. { Of course this Record is on the stack in this example;
  41.  Use a Globel methd or use the VAr in the Parms.
  42. it you use VAR then the Address must be gotten indirectly.
  43. Example:
  44. }  LES  DI, AR;         { THis Loads the Address fo the Array from the STactk
  45.  { Then you go through you same multipy stuff }
  46.